from flask import Flask
from flask_wtf.csrf import CSRFProtect
from flask_bcrypt import Bcrypt

from config import site_config_json
from .views import views

csrf = CSRFProtect()
bcrypt = Bcrypt()

def createAPP(config):
    app = Flask(__name__)
    app.config.from_object(config)

    csrf.init_app(app)
    bcrypt.init_app(app)

    app.context_processor(stie_config)

    app.register_blueprint(views)
    
    return app


def stie_config():
    return dict(site_config=site_config_json)